package userManage.Model.dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.*;
public class connect{
    public static final String URL = "jdbc:mysql:///library";
    public static final String USER = "root";
    public static final String PASSWORD = "wmj18734505818";
    private static Connection conn = null;
    static{
        try {
            //1.加载驱动程序
            Class.forName("com.mysql.cj.jdbc.Driver");
            //2. 获得数据库连接
            System.out.println("Connecting to database...");
            conn = DriverManager.getConnection(URL, USER, PASSWORD);
        }catch(SQLException se){
            //Handle errors for JDBC
            se.printStackTrace();
        }catch(Exception e){
            //Handle errors for Class.forName
            e.printStackTrace();
        }
    }

    public static Connection getConnection(){
        return conn;
    }
}